package com.hhcf.system.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 
 * @Title: OnlineListener
 * @Description:
 * @Author: zhaotf
 * @Since:2017年2月20日 下午1:26:59
 * @Version:1.0
 */
public class OnlineListener implements ServletContextListener, HttpSessionListener {

	private static ApplicationContext ctx = null;

	public OnlineListener() {
	}

	@Override
	public void sessionCreated(HttpSessionEvent httpSessionEvent) {
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
		// ClientManager.getInstance().removeClinet(httpSessionEvent.getSession().getId());
	}

	/**
	 * 服务器初始化
	 */

	@Override
	public void contextInitialized(ServletContextEvent evt) {
		ctx = WebApplicationContextUtils.getWebApplicationContext(evt.getServletContext());
	}

	public static ApplicationContext getCtx() {
		return ctx;
	}

	@Override
	public void contextDestroyed(ServletContextEvent paramServletContextEvent) {

	}

}
